Telegram Group & Telegram Channel
🧩 Сложная задача по Python для опытных разработчиков

Что выведет следующий код?


def func(a, L=[]):
L.append(a)
return L

print(func(1))
print(func(2))
print(func(3))


Варианты ответа:
A)

[2]
[3]

B)

[1, 2]
[1, 2, 3]

C)

[1]
[1]

D)

[2]
[3]


---

Правильный ответ: B

Почему:
Списки по умолчанию (
L=[]) в Python инициализируются один раз при определении функции, а не каждый раз при вызове. Поэтому изменения сохраняются между вызовами func. Это классическая "ловушка" со значениями по умолчанию!

@python_job_interview



tg-me.com/python_job_interview/1068
Create:
Last Update:

🧩 Сложная задача по Python для опытных разработчиков

Что выведет следующий код?


def func(a, L=[]):
L.append(a)
return L

print(func(1))
print(func(2))
print(func(3))


Варианты ответа:
A)

[2]
[3]

B)

[1, 2]
[1, 2, 3]

C)

[1]
[1]

D)

[2]
[3]


---

Правильный ответ: B

Почему:
Списки по умолчанию (
L=[]) в Python инициализируются один раз при определении функции, а не каждый раз при вызове. Поэтому изменения сохраняются между вызовами func. Это классическая "ловушка" со значениями по умолчанию!

@python_job_interview

BY Python вопросы с собеседований


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_job_interview/1068

View MORE
Open in Telegram


Python вопросы с собеседований Telegram | DID YOU KNOW?

Date: |

Telegram Be The Next Best SPAC

I have no inside knowledge of a potential stock listing of the popular anti-Whatsapp messaging app, Telegram. But I know this much, judging by most people I talk to, especially crypto investors, if Telegram ever went public, people would gobble it up. I know I would. I’m waiting for it. So is Sergei Sergienko, who claims he owns $800,000 of Telegram’s pre-initial coin offering (ICO) tokens. “If Telegram does a SPAC IPO, there would be demand for this issue. It would probably outstrip the interest we saw during the ICO. Why? Because as of right now Telegram looks like a liberal application that can accept anyone - right after WhatsApp and others have turn on the censorship,” he says.

What is Telegram?

Telegram is a cloud-based instant messaging service that has been making rounds as a popular option for those who wish to keep their messages secure. Telegram boasts a collection of different features, but it’s best known for its ability to secure messages and media by encrypting them during transit; this prevents third-parties from snooping on messages easily. Let’s take a look at what Telegram can do and why you might want to use it.

Python вопросы с собеседований from ru


Telegram Python вопросы с собеседований
FROM USA